--------------------------------------------------------
--  File created - Tuesday-November-05-2013   
--------------------------------------------------------
DROP TABLE "VIKTOR"."LOCATIONS" cascade constraints;
DROP TABLE "VIKTOR"."USERS" cascade constraints;
DROP TABLE "VIKTOR"."USER_GROUPS" cascade constraints;
DROP TABLE "VIKTOR"."ORDERS" cascade constraints;
--------------------------------------------------------
--  DDL for Sequence LOCATIONS_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "VIKTOR"."LOCATIONS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 81 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Sequence USERS_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "VIKTOR"."USERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 41 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Sequence ORDERS_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "VIKTOR"."ORDERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 81 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Table LOCATIONS
--------------------------------------------------------

  CREATE TABLE "VIKTOR"."LOCATIONS" 
   (	"ID" NUMBER(9,0), 
	"CENTROID" VARCHAR2(50 BYTE), 
	"COUNTRY" VARCHAR2(10 BYTE), 
	"CITY" VARCHAR2(50 BYTE), 
	"STATE" VARCHAR2(50 BYTE), 
	"NAME" VARCHAR2(100 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table USERS
--------------------------------------------------------

  CREATE TABLE "VIKTOR"."USERS" 
   (	"ID" NUMBER(9,0), 
	"LOGIN" VARCHAR2(50 BYTE), 
	"NAME" VARCHAR2(70 BYTE), 
	"SURNAME" VARCHAR2(70 BYTE), 
	"BIRTHDATE" DATE, 
	"PHONE" VARCHAR2(20 BYTE), 
	"REGISTRATION_DATE" DATE, 
	"GROUP_ID" NUMBER(9,1), 
	"BLOCKED" NUMBER(1,0) DEFAULT 0, 
	"REGISTRATION_TOKEN" VARCHAR2(256 CHAR), 
	"PASSWORD" VARCHAR2(64 CHAR), 
	"SALT" VARCHAR2(64 CHAR)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table USER_GROUPS
--------------------------------------------------------

  CREATE TABLE "VIKTOR"."USER_GROUPS" 
   (	"ID" NUMBER(9,0), 
	"NAME" VARCHAR2(30 BYTE), 
	"DISCOUNT" NUMBER(2,0), 
	"COMMISSION" NUMBER(2,0)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table ORDERS
--------------------------------------------------------

  CREATE TABLE "VIKTOR"."ORDERS" 
   (	"ID" NUMBER(9,0), 
	"USER_ID" NUMBER(9,0), 
	"LOCATION_ID" NUMBER(9,0), 
	"ROOMS" NUMBER(1,0), 
	"ADULTS" NUMBER(1,0), 
	"CHILDREN" NUMBER(1,0), 
	"NIGHTS" NUMBER(3,0), 
	"STARS" NUMBER(1,0), 
	"PRICE" FLOAT(126), 
	"DATE_OF_ORDER" DATE, 
	"CHECK_IN_DATE" DATE, 
	"CHECK_OUT_DATE" DATE, 
	"CONFIRMATION_TOKEN" VARCHAR2(50 CHAR), 
	"CONFIRMED" NUMBER(1,0) DEFAULT 0
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
REM INSERTING into VIKTOR.LOCATIONS
SET DEFINE OFF;
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (22,'42.474564,-83.248538','US','Southfield','MI','Southfield');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (44,'42.354346,-83.049717','US','Detroit','MI','Detroit Downtown');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (63,'42.480714,-83.440637','US','Farmington','MI','Novi - Farmington Hills');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (64,'42.480714,-83.440637','US','Farmington','MI','Novi - Farmington Hills');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (65,'42.480714,-83.440637','US','Farmington','MI','Novi - Farmington Hills');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (66,'42.480714,-83.440637','US','Farmington','MI','Novi - Farmington Hills');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (61,'42.387743,-83.381708','US','Livonia','MI','Livonia');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (41,'42.5597,-83.1852','US','Birmingham','MI','Birmingham - Troy - Madison Heights');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (42,'42.354346,-83.049717','US','Detroit','MI','Detroit Downtown');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (62,'42.480714,-83.440637','US','Farmington','MI','Novi - Farmington Hills');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (67,'42.480714,-83.440637','US','Farmington','MI','Novi - Farmington Hills');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (68,'42.3064,-83.2186','US','Dearborn','MI','Dearborn - Allen Park - Melvindale');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (69,'42.474564,-83.248538','US','Southfield','MI','Southfield');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (70,'42.5597,-83.1852','US','Birmingham','MI','Birmingham - Troy - Madison Heights');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (71,'42.665478,-83.144599','US','Rochester','MI','Rochester - Rochester Hills');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (72,'42.5331,-82.8972','US','Roseville','MI','Roseville');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (73,'42.234012,-83.338913','US','Brownstown','MI','Detroit Intl Airport DTW');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (74,'42.337404,-83.448994','US','Canton','MI','Plymouth - Canton');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (75,'42.387743,-83.381708','US','Livonia','MI','Livonia');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (23,'42.525705,-83.038998','US','Sterling Heights','MI','Warren - Sterling Heights');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (43,'42.474564,-83.248538','US','Southfield','MI','Southfield');
Insert into VIKTOR.LOCATIONS (ID,CENTROID,COUNTRY,CITY,STATE,NAME) values (21,'42.3064,-83.2186','US','Dearborn','MI','Dearborn - Allen Park - Melvindale');
REM INSERTING into VIKTOR.USERS
SET DEFINE OFF;
Insert into VIKTOR.USERS (ID,LOGIN,NAME,SURNAME,BIRTHDATE,PHONE,REGISTRATION_DATE,GROUP_ID,BLOCKED,REGISTRATION_TOKEN,PASSWORD,SALT) values (33,'nahtlol@gmail.com','qqq',null,null,'222',to_date('21-OCT-13','DD-MON-RR'),2,0,'cfb968c4-7561-4dab-a0cc-ffc90f5fab20','57CD12BA1A79AB2203E407116D152B4A0AF14D61796688FF3BD85415CA058FBF','F21415FEA49C126D7DB9F0D4FB738F8F260CCAFC5D4355BE5A7552636322A3B5');
Insert into VIKTOR.USERS (ID,LOGIN,NAME,SURNAME,BIRTHDATE,PHONE,REGISTRATION_DATE,GROUP_ID,BLOCKED,REGISTRATION_TOKEN,PASSWORD,SALT) values (35,'viktor.melnic@gmail.com','www',null,null,'222',to_date('21-OCT-13','DD-MON-RR'),4,0,'f3d5df64-8d0d-476f-8ea2-7d072db30888','9A1151333E2E0E203BE48A699AD37A38CB2C3738B8779FDD34C951DCBA99FBA7','81FCCFC6EE94708BE10277B6ABAE2381C72804D8FBB602A0C6A881F6CFFF1FBB');
REM INSERTING into VIKTOR.USER_GROUPS
SET DEFINE OFF;
Insert into VIKTOR.USER_GROUPS (ID,NAME,DISCOUNT,COMMISSION) values (1,'administrator',15,10);
Insert into VIKTOR.USER_GROUPS (ID,NAME,DISCOUNT,COMMISSION) values (2,'manager',15,10);
Insert into VIKTOR.USER_GROUPS (ID,NAME,DISCOUNT,COMMISSION) values (3,'vip user',15,10);
Insert into VIKTOR.USER_GROUPS (ID,NAME,DISCOUNT,COMMISSION) values (4,'registered user',5,10);
Insert into VIKTOR.USER_GROUPS (ID,NAME,DISCOUNT,COMMISSION) values (5,'not registered user',0,10);
REM INSERTING into VIKTOR.ORDERS
SET DEFINE OFF;
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (65,33,63,1,0,0,2,3,149.02,to_date('03-NOV-13','DD-MON-RR'),to_date('11-APR-13','DD-MON-RR'),to_date('11-JUN-13','DD-MON-RR'),'e81115f3-0b80-4b96-9bac-b6dca86af4a7',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (66,33,63,1,0,0,9,3,602.04,to_date('03-NOV-13','DD-MON-RR'),to_date('20-NOV-13','DD-MON-RR'),to_date('29-NOV-13','DD-MON-RR'),'9ca52dd6-7d74-4a55-8bc9-f6f74436fe51',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (67,33,63,1,0,0,17,3,1180.52,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'56b1edbf-ad32-47f8-bf1f-c70201542106',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (68,33,68,1,0,0,17,4,1354.21,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'096ceb40-0077-48ac-8945-9bf74481a3cb',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (69,33,22,1,0,0,17,3,990.04,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'3c04a918-9524-4b5f-94dc-13d6a8c195d5',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (70,33,41,1,0,0,17,2,742.14,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'7699012e-3af4-4879-b255-1d64e9888b8a',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (71,33,71,1,0,0,17,2,755.24,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'028793c8-03e5-4a00-9235-9b52f701d771',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (72,33,72,1,0,0,17,2,929.31,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'883bc37f-71c9-467a-bf22-d10d0424c743',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (73,33,73,1,0,0,17,3,2012.82,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'9508b285-4135-4d55-a0e4-7844606d9d25',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (74,33,74,1,0,0,17,1,870.33,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'c9732f90-1811-49f9-bba6-40f2e3b1df04',0);
Insert into VIKTOR.ORDERS (ID,USER_ID,LOCATION_ID,ROOMS,ADULTS,CHILDREN,NIGHTS,STARS,PRICE,DATE_OF_ORDER,CHECK_IN_DATE,CHECK_OUT_DATE,CONFIRMATION_TOKEN,CONFIRMED) values (75,33,61,1,0,0,17,2,836.21,to_date('03-NOV-13','DD-MON-RR'),to_date('05-NOV-13','DD-MON-RR'),to_date('22-NOV-13','DD-MON-RR'),'f822c750-3b59-43c9-acfa-98d4ed0207b4',0);
--------------------------------------------------------
--  DDL for Index LOCATIONS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "VIKTOR"."LOCATIONS_PK" ON "VIKTOR"."LOCATIONS" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index USERS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "VIKTOR"."USERS_PK" ON "VIKTOR"."USERS" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index USER_GROUPS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "VIKTOR"."USER_GROUPS_PK" ON "VIKTOR"."USER_GROUPS" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index ORDERS
--------------------------------------------------------

  CREATE UNIQUE INDEX "VIKTOR"."ORDERS" ON "VIKTOR"."ORDERS" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  Constraints for Table LOCATIONS
--------------------------------------------------------

  ALTER TABLE "VIKTOR"."LOCATIONS" ADD CONSTRAINT "LOCATIONS_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "VIKTOR"."LOCATIONS" MODIFY ("NAME" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."LOCATIONS" MODIFY ("CITY" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."LOCATIONS" MODIFY ("COUNTRY" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."LOCATIONS" MODIFY ("CENTROID" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."LOCATIONS" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table USERS
--------------------------------------------------------

  ALTER TABLE "VIKTOR"."USERS" MODIFY ("SALT" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("REGISTRATION_TOKEN" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("PASSWORD" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" ADD CONSTRAINT "USERS_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("BLOCKED" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("GROUP_ID" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("REGISTRATION_DATE" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("NAME" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("LOGIN" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USERS" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table USER_GROUPS
--------------------------------------------------------

  ALTER TABLE "VIKTOR"."USER_GROUPS" ADD CONSTRAINT "USER_GROUPS_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "VIKTOR"."USER_GROUPS" MODIFY ("COMMISSION" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USER_GROUPS" MODIFY ("DISCOUNT" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USER_GROUPS" MODIFY ("NAME" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."USER_GROUPS" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table ORDERS
--------------------------------------------------------

  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("CONFIRMED" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("CONFIRMATION_TOKEN" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" ADD CONSTRAINT "ORDERS" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("CHECK_OUT_DATE" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("CHECK_IN_DATE" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("DATE_OF_ORDER" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("PRICE" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("LOCATION_ID" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("USER_ID" NOT NULL ENABLE);
  ALTER TABLE "VIKTOR"."ORDERS" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Ref Constraints for Table USERS
--------------------------------------------------------

  ALTER TABLE "VIKTOR"."USERS" ADD CONSTRAINT "USERS_FK" FOREIGN KEY ("GROUP_ID")
	  REFERENCES "VIKTOR"."USER_GROUPS" ("ID") ON DELETE CASCADE ENABLE;
--------------------------------------------------------
--  Ref Constraints for Table ORDERS
--------------------------------------------------------

  ALTER TABLE "VIKTOR"."ORDERS" ADD CONSTRAINT "ORDERS_FK" FOREIGN KEY ("USER_ID")
	  REFERENCES "VIKTOR"."USERS" ("ID") ON DELETE CASCADE ENABLE;
  ALTER TABLE "VIKTOR"."ORDERS" ADD CONSTRAINT "ORDERS_FK2" FOREIGN KEY ("LOCATION_ID")
	  REFERENCES "VIKTOR"."LOCATIONS" ("ID") ON DELETE CASCADE ENABLE;
--------------------------------------------------------
--  DDL for Trigger TRIGGER2
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "VIKTOR"."TRIGGER2" 
   before insert on "VIKTOR"."LOCATIONS" 
   for each row 
begin  
   if inserting then 
      if :NEW."ID" is null then 
         select LOCATIONS_SEQ.nextval into :NEW."ID" from dual; 
      end if; 
   end if; 
end;

/
ALTER TRIGGER "VIKTOR"."TRIGGER2" ENABLE;
--------------------------------------------------------
--  DDL for Trigger TRIGGER1
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "VIKTOR"."TRIGGER1" 
   before insert on "VIKTOR"."USERS" 
   for each row 
begin  
   if inserting then 
      if :NEW."ID" is null then 
         select USERS_SEQ.nextval into :NEW."ID" from dual; 
      end if; 
   end if; 
end;

/
ALTER TRIGGER "VIKTOR"."TRIGGER1" ENABLE;
--------------------------------------------------------
--  DDL for Trigger TRIGGER3
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "VIKTOR"."TRIGGER3" 
   before insert on "VIKTOR"."ORDERS" 
   for each row 
begin  
   if inserting then 
      if :NEW."ID" is null then 
         select ORDERS_SEQ.nextval into :NEW."ID" from dual; 
      end if; 
   end if; 
end;

/
ALTER TRIGGER "VIKTOR"."TRIGGER3" ENABLE;
--------------------------------------------------------
--  DDL for Synonymn DUAL
--------------------------------------------------------

  CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "SYS"."DUAL";
